/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package myconfession.utils;

import java.sql.Connection;
import java.sql.SQLException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

/**
 *
 * @author Liem
 */
public class SQLConnection {

    private SQLConnection() {
    }

    public static Connection getConnection() throws NamingException, SQLException {
        Context context = new InitialContext();
        Context envCtx = (Context) context.lookup(("java:comp/env"));
        DataSource dataSource = (DataSource) envCtx.lookup("DBCon");
        Connection connection = dataSource.getConnection();
        return connection;
    }
}
